﻿@model Numeria.IO.EntryInfo[]
<!DOCTYPE html>
<html>
<head>
    <title>FileDB</title>
    <style>
    .container { border: 1px solid black; padding: 5px 0px 0px 5px; }
    .container .item { border: 1px solid gray; padding: 5px; margin: 0px 5px 5px 0px; display: inline-block; width: 240px; }
    .container .item img { float: left; margin-right: 5px; }
    .upload-frame { border: 1px solid gray; padding: 10px; margin-bottom: 10px; }
    </style>
    <link rel="Stylesheet" href="/Content/fileuploader.css" />
    <script language="javascript" type="text/javascript" src="/Content/fileuploader.js"></script>
    <script language="javascript" type="text/javascript">

        window.onload = function () {
            var uploader = new qq.FileUploader({
                element: document.getElementById('file-uploader'),
                action: '/UploadJSON',
                debug: true,
                onComplete: function (id, fileName, responseJSON) {
                    if (uploader._filesInProgress == 0)
                        location.replace(location.href);
                }
            });
        }
    
    </script>
</head>
<body>

    <h1>FileDB</h1>
    <hr />

    <h2>Upload</h2>

    <div class="upload-frame">
        <i>From normal &lt;input type="file" &gt;</i>
        <form action="/Upload" method="post" enctype="multipart/form-data">
            <input type="file" name="file" /><input type="submit" value="Submit" />
        </form> 
    </div>

    <div class="upload-frame">
        <i>From external library (http://github.com/valums/file-uploader)</i>
        <div id="file-uploader"></div>
    </div>

    <hr />

    <h2>List</h2>
    <p>Total Files: @ViewData["TotalFiles"]</p>
    <a href="/DeleteAll">Delete All Files</a> - <a href="/Shrink">Shrink FileDB</a> - <a href="/Structure">View FileDB Structure</a>

    <div class="container">

    @foreach(var file in Model) {
        <div class="item">
            <img src="/Thumbnail/@file.ID" />
            <label>@file.FileName</label><br />
            @Html.FormatFileLength(file.FileLength) <br />
            <a href="/Download/@file.ID">Download</a>
            <a href="/Delete/@file.ID">Delete</a>
        </div>
    }
    @if (Model.Length == 0) { <div>No Files</div> }
    </div>

</body>
</html>
